#!/bin/bash

ID=/home/EchoIRLP

mkdir $ID/backup >/dev/null 2>&1

cd $ID

tar -X $ID/scripts/nobackup.list --exclude=stn*.wav --exclude=ref*.wav \
 -zcvf $ID/backup/echoirlp_backup.tgz ./*

SIZE=`du -b $ID/backup/echoirlp_backup.tgz | cut -d"/" -f1`
echo The backup file is $SIZE bytes in size.

if [ "$SIZE" -gt "1300000" ] ; then
  echo "This image could not fit on a floppy. You must use the WinSCP method"
  echo "to transfer the backup to your new node."
else
  echo -n "Would you like to backup the file onto a floppy? (y/N) : " ; read YESNO
  if [ "$YESNO" = "y" ] || [ $"YESNO" = "Y" ] ; then
    echo "Please insert a DOS formatted floppy now. Press Enter when ready." ; read
    mount /dev/fd0 /mnt/floppy
    cp $ID/backup/echoirlp_backup.tgz /mnt/floppy
    umount /dev/fd0
    echo "Once the drive light is out, you can remove the floppy."
  fi
fi

echo "IRLP Backup Complete"
